var app = getApp(),
  $ = require("../../utils/httpHelper.js");
Page({
  data: {
    nav: ["今日收益", "近一个月","近三个月","全部"],
    currnav:0,
    zong:"",
    page: 1,
    pagesize: 7,
    totalpage: 0,//最大页数
    height: 0,
    nomore: true,
    types:0,
    monlist:[]
  },
  onLoad: function (options) {
   var that=this
   wx.getSystemInfo({
     success: function (res) {
       that.setData({ height: res.windowHeight })
     }
   })
   this.getData()
  },
  onShow: function () {
    
  },
  getData() {
    let par = {
      rd_session: app.globalData.userInfo.rd_session,
      types: this.data.types,
      page: this.data.page,
      pagesize: this.data.pagesize,
    }
    $.httpPost("finance_record", par, (data, err) => {
      this.setData({
        monlist: data.data.list,
        totalpage: data.data.total_page,
        zong: data.data.total_fee
      })
    })
  },
  currrnav: function (e) {
    console.log(e)
    var currnav = e.currentTarget.dataset.index
    this.setData({
      currnav: currnav,
      page: 1,
      types: currnav
    })
    this.getData()
  },
  //滑动到底部 上拉加载
  scrollBottom: function () {
    this.data.page++
    if (this.data.page > this.data.totalpage) {
      this.setData({
        nomore: false
      })
    } else {
      let params = {
        rd_session: app.globalData.userInfo.rd_session,
        page: this.data.page,
        pagesize: this.data.pagesize,
        types: this.data.types
      }
      $.httpPost("finance_record", params, (data, err) => {
        let arr = this.data.monlist;
        for (let item of data.data.list) {
          arr.push(item);
        }
        this.setData({
          monlist: arr,
        })
      })
    }

  },
})